<template>
	<view class="pinOrder">
		<view class="pinOrder_one">
			<view class="one_title" :class="{'one_titleActive':pinIndex==indexs}" v-for="(items,indexs) in pinNav"
				@click="pinIndex=indexs,page=1,gettuOrder('init')">
				{{items}}
				<view class="one_title_line" v-if="indexs==pinIndex">

				</view>
			</view>
		</view>
		<view class="pinOrder_count">
			<view class="count_one" v-for="(itemed,indexed) in orderlist" :key="indexed">
				<view class="count_one_title">
					订单号：
					<view class="title_right">
						{{itemed.order_no}}
					</view>
				</view>
				<view class="count_one_time">
					<view class="one_time_left">
						周期：{{itemed.day}}天
					</view>
					<view class="one_time_right">
						{{itemed.status==0?'未结算':'已结算'}}
					</view>
				</view>
				<view class="count_one_price">
					KDJ：{{itemed.kdj}} <span>蝌蚪积分：{{itemed.kd_score}}</span>
				</view>
				<view class="jindu_title">
					奖励发放进度：{{itemed.order_day}}/{{itemed.day}}
				</view>
				<view class="jindu_title">
					下单时间：{{itemed.createtime}}
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				pinNav: ['未结算', '已结算'],
				pinIndex: 0,
				page: 1,
				last_page: 1,
				orderlist: [],
			}
		},
		onLoad() {
			this.gettuOrder('init')
		},
		onPullDownRefresh() {
			setTimeout(()=>{
				uni.stopPullDownRefresh()
			},1500)
			this.gettuOrder('init')
		},
		onReachBottom() {
			if(this.last_page>this.page){
				this.page++
				this.gettuOrder()
			}
		},
		methods: {
			async gettuOrder(type) {
				if (type == 'init') {
					this.page = 1
					this.orderlist = []
				}
				await uni.request({
					url: "/wanlshop/Signin/tu_order_list",
					method: "POST",
					data: {
						page: this.page,
						status: this.pinIndex
					},
					success: (res) => {
						this.last_page = res.data.last_page
						if (res.data.data.length) {
							if (this.page == 1) {
								this.orderlist = res.data.data
							} else {
								this.orderlist = [...this.orderlist, ...res.data.data]
							}
						}
						console.log(res.data, '拼图订单')
					}
				})
			}
		}
	}
</script>
<style lang="scss" scoped>
	@import "work";
</style>